
// npx babel-node str01.js

let test01 = function() {
    console.log((x => x * 2)(1));

    const a = "\uD842\uDFB7";
    const b = "\u{20BB7}";

    // 遗憾, 输出结果为乱码
    console.log(`a: ${a}, b: ${b}`);
};

// for ... of
let test02 = function() {
    for (let codePoint of 'foo') {
        console.log(codePoint)
    }
};

// test02()

let test03 = function() {
    let text = String.fromCodePoint(0x20BB7);

    for (let i = 0; i < text.length; i++) {
        console.log(text[i]);
    }

    for (let i of text) {
        console.log(i);
    }
};

// test03();

let test04 = function(){
    const json = '"\u2028"';
    JSON.parse(json);

    const PS = eval("'\u2029'");
    console.log(PS);
};

// test04();

let test05 = function() {
    let _ = JSON.stringify('\u{D834}');
    console.log(_)
    _ = JSON.stringify('\uDF06\uD834');
    console.log(_)
};

// test05();

let test06 = function(){
    // 普通字符串
    let _ = `In JavaScript '\n' is a line-feed.`;
    console.log(_);

    // 多行字符串
    _ = `In JavaScript this is
not legal.`;
    
    console.log(_);

    console.log(`string text line 1
string text line 2`);

    // 字符串中嵌入变量
    let name = "Bob", time = "today";
    _ = `Hello ${name}, how are you ${time}?`
    console.log(_);
};

// test06();







